Programming With QuickTime VR

| Previous | Chapter Contents | Chapter Top | Next |

Displaying QuickTime VR Movies

QuickTime VR movies are simply a special kind of QuickTime movie, so it's easy to add support to your application for playing QuickTime VR movies. If the QuickTime VR Manager (and hence the QuickTime VR movie controller) is available, you simply open a movie using standard QuickTime functions, call NewMovieController to associate the movie with the QuickTime VR movie controller, and make the appropriate call to MCIsPlayerEvent in your main event loop. These are exactly the same steps you follow to open and manage any QuickTime movie. Listing 1-1 shows a typical way to open a QuickTime VR movie.

Listing 1 Opening a QuickTime VR movie

Movie MyGetMovie (void)
{
    OSErr                   myErr;
    SFTypeList              myTypes = {MovieFileType, 0, 0, 0};
    StandardFileReply       myReply;
    Movie                   myMovie = nil;
    short                   myResFile;

    StandardGetFilePreview(nil, 1, myTypes, &myReply);
    if (myReply.sfGood)
    { myErr = OpenMovieFile(&myReply.sfFile, &myResFile, fsRdPerm);
        if (myErr == noErr) {
            short           myResID = 0;        //We want the first movie.
            Str255          myName;
            Boolean         wasChanged;
        
            myErr = NewMovieFromFile(&myMovie, myResFile, &myResID, myName,
                                    newMovieActive, &wasChanged);
            CloseMovieFile(myResFile);
        }
    }
    return(myMovie);
}

It's important to notice that Listing 1-1 does not use the QuickTime VR Manager at all. Instead, it relies entirely on QuickTime's Movie Toolbox and other Macintosh system software managers.

See QuickTime 3 Reference for a complete description of the Movie Toolbox.

Once you've opened a file containing a QuickTime VR movie, you need to call NewMovieController to obtain the standard user interface for playing QuickTime VR movies. It's particularly important that you call NewMovieController (rather than call the Component Manager directly) for QuickTime VR movies, because QuickTime VR movies contain special information that lets QuickTime know which movie controller to load.

In your main event loop, you should pass all events to the MCIsPlayerEvent function, which passes user events (such as mouse movements and button clicks) to the QuickTime VR movie controller. QuickTime VR automatically changes the cursor's shape when it's inside the movie's boundary. As a result, your application should relinquish control of the cursor for as long as it remains in the movie's boundary and then reset the cursor's shape as necessary when it is moved outside the movie.

To allow the QuickTime VR movie controller to update the shape of the cursor in a timely manner, your application should pass all events, even idle events, to the MCIsPlayerEvent function. Alternatively, you can call the MCIdle function frequently.

If you want to disable the automatic cursor tracking and shape changing provided by the QuickTime VR movie controller, you can execute this line of code, where myMC is an identifier for a movie controller returned by NewMovieController :

MCDoAction(myMC, mcActionSetCursorSettingEnabled, (void*) false);

The mcActionSetCursorSettingEnabled movie controller action was introduced in QuickTime version 2.1. See the chapter "QuickTime VR Movie Controller" in this book for a description of how the QuickTime VR movie controller handles this and other movie controller actions.


© 1998 Apple Computer, Inc.

| Previous | Chapter Contents | Chapter Top | Next |